// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   RTO_INTImpl.java

package com.sunwayhorizo.health.hl7.datatypes.common;

import com.sunwayhorizo.health.hl7.common.Hl7Exception;
import com.sunwayhorizo.health.hl7.datatypes.ANY;
import com.sunwayhorizo.health.hl7.datatypes.BL;
import com.sunwayhorizo.health.hl7.datatypes.CS;
import com.sunwayhorizo.health.hl7.datatypes.INT;
import com.sunwayhorizo.health.hl7.datatypes.QTY;
import com.sunwayhorizo.health.hl7.datatypes.RTO_INT;
import com.sunwayhorizo.health.hl7.datatypes.ST;
import com.sunwayhorizo.health.hl7.datatypes.TYPE;


// Referenced classes of package oracle.apps.ctb.hl7.types.common:
//            ANYImpl, BLImpl, CSImpl, INTImpl, 
//            STImpl, TYPEImpl

public class RTO_INTImpl extends ANYImpl
    implements RTO_INT
{

    public static final String RCS_ID = "$Header: RTO_INTImpl.java 115.19 2005/09/16 09:23:38 amchanda noship $";
    private INT mNumerator;
    private INT mDenominator;
    private static final RTO_INT nullNI = new RTO_INTImpl(CSImpl.valueOf("NI"));
    private static final RTO_INT nullOTH = new RTO_INTImpl(CSImpl.valueOf("OTH"));
    private static final RTO_INT nullNINF = new RTO_INTImpl(CSImpl.valueOf("NINF"));
    private static final RTO_INT nullPINF = new RTO_INTImpl(CSImpl.valueOf("PINF"));
    private static final RTO_INT nullUNK = new RTO_INTImpl(CSImpl.valueOf("UNK"));
    private static final RTO_INT nullASKU = new RTO_INTImpl(CSImpl.valueOf("ASKU"));
    private static final RTO_INT nullNAV = new RTO_INTImpl(CSImpl.valueOf("NAV"));
    private static final RTO_INT nullMSK = new RTO_INTImpl(CSImpl.valueOf("MSK"));
    private static final RTO_INT nullNA = new RTO_INTImpl(CSImpl.valueOf("NA"));
    private static final RTO_INT nullNASK = new RTO_INTImpl(CSImpl.valueOf("NASK"));

    protected RTO_INTImpl(INT int1, INT int2)
    {
        if(int1 == null || int1.isNull().isTrue())
            mNumerator = INTImpl.valueOf(1L);
        else
            mNumerator = int1;
        if(int2 == null || int2.isNull().isTrue())
            mDenominator = INTImpl.valueOf(1L);
        else
            mDenominator = int2;
        if(mDenominator.intValue() == 0)
            throw ANYImpl.newRatioException("RTO<INT>");
        else
            return;
    }

    protected RTO_INTImpl()
    {
        mNumerator = INTImpl.valueOf(1L);
        mDenominator = INTImpl.valueOf(1L);
    }

    protected RTO_INTImpl(CS cs)
    {
        super(true, cs);
        mNumerator = null;
        mDenominator = null;
    }

    public static RTO_INT valueOf(INT int1, INT int2)
    {
        return new RTO_INTImpl(int1, int2);
    }

    public static RTO_INT valueOf()
    {
        return new RTO_INTImpl();
    }

    public static RTO_INT nullRTO_INT()
    {
        return new RTO_INTImpl(null);
    }

    public BL equal(ANY any)
    {
        if(!(any instanceof RTO_INT))
            return BLImpl.FALSE;
        if(isNull().or(any.isNull()).isTrue())
        {
            return BLImpl.FALSE;
        } else
        {
            RTO_INT rto_int = (RTO_INT)any;
            return mNumerator.equal(rto_int.numerator()).or(mNumerator.isNull().and(rto_int.numerator().isNull())).and(mDenominator.equal(rto_int.denominator()).or(mDenominator.isNull().and(rto_int.denominator().isNull())));
        }
    }

    public TYPE dataType()
    {
        return com.sunwayhorizo.health.hl7.datatypes.common.TYPEImpl.RTO_INT;
    }

    public TYPE diffType()
    {
        return com.sunwayhorizo.health.hl7.datatypes.common.TYPEImpl.RTO_INT;
    }

    public ST literal()
    {
        return STImpl.valueOf(numerator().toString() + ":" + denominator().toString());
    }

    public INT numerator()
    {
        return mNumerator;
    }

    public INT denominator()
    {
        return mDenominator;
    }

    public int hashCode()
    {
        int i = 17;
        if(isNull().isFalse())
        {
            i = 37 * i + numerator().hashCode();
            i = 37 * i + denominator().hashCode();
        }
        return i;
    }

//    public XMLNode[] writeXML(XMLDocument xmldocument, String s)
//        throws Hl7Exception
//    {
//        try
//        {
//            XMLElement xmlelement = (XMLElement)xmldocument.createElement(s);
//            if(numerator() != null && numerator().isNull().isFalse())
//                xmlelement.appendChild(((INTImpl)numerator()).writeXML(xmldocument, "numerator")[0]);
//            if(denominator() != null && denominator().isNull().isFalse())
//                xmlelement.appendChild(((INTImpl)denominator()).writeXML(xmldocument, "denominator")[0]);
//            return (new XMLNode[] {
//                xmlelement
//            });
//        }
//        catch(Exception exception)
//        {
//            throw new Hl7Exception(exception);
//        }
//    }

    public QTY minus(QTY qty)
    {
        throw ANYImpl.newUnsupportedException("RTO<INT>", "minus");
    }

    public QTY plus(QTY qty)
    {
        throw ANYImpl.newUnsupportedException("RTO<INT>", "plus");
    }

    public BL isZero()
    {
        throw ANYImpl.newUnsupportedException("RTO<INT>", "isZero");
    }

    public BL lessThan(QTY qty)
    {
        throw ANYImpl.newUnsupportedException("RTO<INT>", "lessThan");
    }

    public BL greaterOrEqual(QTY qty)
    {
        throw ANYImpl.newUnsupportedException("RTO<INT>", "greaterOrEqual");
    }

    public BL greaterThan(QTY qty)
    {
        throw ANYImpl.newUnsupportedException("RTO<INT>", "greaterThan");
    }

    public BL lessOrEqual(QTY qty)
    {
        throw ANYImpl.newUnsupportedException("RTO<INT>", "lessOrEqual");
    }

    public BL compares(QTY qty)
    {
        throw ANYImpl.newUnsupportedException("RTO<INT>", "compares");
    }

    public static RTO_INT nullRTO_INT(CS cs)
    {
        String s = null;
        if(cs == null || cs.literal().stringValue() == null || cs.isNull().isTrue())
            s = "NI";
        else
            s = cs.literal().stringValue();
        if(s.equals("NI"))
            return nullNI;
        if(s.equals("OTH"))
            return nullOTH;
        if(s.equals("NINF"))
            return nullNINF;
        if(s.equals("PINF"))
            return nullPINF;
        if(s.equals("UNK"))
            return nullUNK;
        if(s.equals("ASKU"))
            return nullASKU;
        if(s.equals("NAV"))
            return nullNAV;
        if(s.equals("MSK"))
            return nullMSK;
        if(s.equals("NA"))
            return nullNA;
        if(s.equals("NASK"))
            return nullNASK;
        else
            return nullNI;
    }

}
